package misc

import (
	"dhfshop/controllers/base"
	"dhfshop/models/misc"
)

// 行政区域管理
type AreaController struct {
	base.BaseController
}

func (this *AreaController) AreaList() {
	query, _, fields, order_by, offset, limit, err := this.GetQueryPara()
	if err != nil {
		this.ServeError(err.Error())
		return
	}
	l, cnt, err := misc.GetAllAreas(query, fields, order_by, offset, limit)
	if err != nil {
		this.ServeError(err.Error())
		return
	}
	r := struct {
		TotalCount int64        `json:"total_count"`
		Areas      []*misc.Area `json:"areas"`
	}{TotalCount: cnt, Areas: l}
	this.Data["json"] = r
	this.ServeJSON()
}
